package demoxsgl_300.com.gouwu1500.adapter;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import demoxsgl_300.com.gouwu1500.R;
import demoxsgl_300.com.gouwu1500.base.Base_Z_Adapter;
import demoxsgl_300.com.gouwu1500.base.MyApplication;
import demoxsgl_300.com.gouwu1500.bean.Bean;
import demoxsgl_300.com.gouwu1500.bean.Water;


/**
 * Created by 他的猫 on 2016/12/3.
 * 适配器
 */

public class FaZuo_Adapter extends Base_Z_Adapter {
    FaZuo_Adapter.Holder holder;
    ListView listView;

    public FaZuo_Adapter(ListView listView) {
        this.listView = listView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        // 查找控件
        if (null == convertView) {
            convertView = LayoutInflater.from(MyApplication.getInstance())
                    .inflate(R.layout.tab_item_1_bingzheng, null);
            holder = new FaZuo_Adapter.Holder();
            holder.times = (TextView) convertView
                    .findViewById(R.id.times);
            holder.title = (RelativeLayout) convertView
                    .findViewById(R.id.title);
            // 缓存Holder
            convertView.setTag(holder);
        } else {
            holder = (FaZuo_Adapter.Holder) convertView.getTag();
        }
        Bean.FazuoteidanBean item = (Bean.FazuoteidanBean) getItem(position);
        holder.times.setText(item.getName());
        if (listView.isItemChecked(position)) {
            holder.title.setBackground(MyApplication.getInstance().getResources().getDrawable(R.drawable.xuanzhong));
        } else {
            holder.title.setBackground(MyApplication.getInstance().getResources().getDrawable(R.drawable.weixuanzhong));
        }
        return convertView;
    }

    public class Holder {
        TextView times;
        RelativeLayout title;

    }
}
